
#include <gtest/gtest.h>
#include <spdlog/spdlog.h>
#include <gdstk/gdstk.hpp>
#include <iostream>

using namespace gdstk;

// TEST(GdstkReadOasTest, BasicAssertion) {
//   Library lib = {};
//   lib.init("library", 1e-6, 1e-9);

//   Cell cell = {};
//   cell.name = copy_string("FIRST", NULL);
//   lib.cell_array.append(&cell);

//   Polygon rect = rectangle(Vec2{0, 0}, Vec2{2, 1}, make_tag(0, 0));
//   cell.polygon_array.append(&rect);

//   lib.write_gds("first.gds", 0, NULL);
//   lib.write_oas("first.oas", 0, 6, OASIS_CONFIG_DETECT_ALL);
//   cell.write_svg("first.svg", 10, 6, NULL, NULL, "#222222", 5, true, NULL);

//   rect.clear();
//   cell.clear();
//   lib.clear();

//   EXPECT_EQ(1, 1);
// }

TEST(GdstkWriteOasTest, BasicAssertion) {
  // const char* file = "D:/bylz/projects/cpp-template/data/138bit_line12.gds";
  // const char* file = "E:/users/xqf/cpp-template/data/138bit_line12.gds";
  const char* file = "C:/Users/xqf/Desktop/project/qlayout-test/data/gds/topcell.gds";
  ErrorCode error_code;
  Set<Tag> shape_tags = {};
  auto lib = read_gds(file, 1e-6, 1e-9, &shape_tags, &error_code);
  SPDLOG_INFO("read_gds ok~");

  const char* oas_file = "C:/Users/xqf/Desktop/project/qlayout-test/data/gds/topcell.oas";
  auto oas_lib = read_oas(file, 1e-6, 0, &error_code);
  SPDLOG_INFO("read_oas ok~");

  const char* out_file = "C:/Users/xqf/Desktop/project/qlayout-test/data/gds/topcell_out.oas";
  oas_lib.write_oas(out_file, 0, 3, OASIS_CONFIG_STANDARD_PROPERTIES);
  SPDLOG_INFO("write_oas ok~");
  // lib.write_oas(out_file, 1e-2, 2, );
  EXPECT_EQ(1, 1);
}

int main(int argc, char* argv[]) {

  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
